import { domainService } from '~/config/server'
import { NetService } from '~/utils/net.service'
import { Inject, Debounce } from "~/core/decorator";
export class RepairCasesService {

  @Inject(NetService)
  private netService: NetService


  /**
   * 信修案件查询
   */
  public repairCasesQuery(data, page) {
    const reqData = { ...data, overdueDaysMin: data.overdueDays.min, overdueDaysMax: data.overdueDays.max }
    delete reqData.overdueDays
    return this.netService.send({
      server: domainService.repairCasesController.repairCasesQuery,
      data: reqData,
      page
    })
  }

  /**
   *  添加案件修复信息 
   */
  @Debounce()
  public toRepair(data) {
    return this.netService.send({
      server: domainService.repairCasesController.toRepair,
      data,
      loading: true
    })
  }


  /**
   * 查询修复信息
   */
  public queryRepairCaseInfo(caseId: string) {
    return this.netService.send({
      server: domainService.repairCasesController.queryRepairCaseInfo,
      data: { caseId }
    })
  }

  /**
   * 信修案件池-分案
   */
  public distributeRepairCases(data) {
    return this.netService.send({
      server: domainService.repairCasesController.distributeRepairCases,
      data,
      loading: true
    })
  }
  /**
   * 查看附件信息
   */
  public viewUploadFile(fileIdsStr: string) {
    return this.netService.send({
      server: domainService.repairCasesController.viewUploadFile,
      data: {
        fileIds: fileIdsStr
      }
    })
  }

  public getCollectionTypeByCaseId(caseId) {
    return this.netService.send({
      server: domainService.repairCasesController.getCollectionTypeByCaseId,
      data: {
        caseId
      }
    })
  } 

  /**
   * 信修案件批量下载
   */
  public downRepairCaseInfos(data) {
    const reqData = { ...data, overdueDaysMin: data.overdueDays.min, overdueDaysMax: data.overdueDays.max }
    delete reqData.overdueDays
    return this.netService.send({
      server: domainService.repairCasesController.downRepairCaseInfos,
      data: reqData
    })
  }

}
